package o;

import android.content.Context;
import android.content.res.Configuration;
import android.os.Handler;
import android.os.Looper;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import androidx.annotation.NonNull;
import o.dfe.d;

final class dfb extends LinearLayout implements OnClickListener {
    private int ˊ;
    private dfa ˋ;
    private Context ˏ;

    public dfb(@NonNull Context context, @NonNull dfa o_dfa) {
        super(context);
        this.ˏ = context;
        this.ˋ = o_dfa;
        ˊ();
        setOnClickListener(this);
    }

    private void ˊ() {
        setBackgroundColor(0);
        setLayoutParams(new LayoutParams(-1, -1));
        if (this.ˏ != null) {
            this.ˊ = this.ˏ.getResources().getConfiguration().orientation;
        }
    }

    public void onClick(View view) {
        if (this.ˋ != null) {
            this.ˋ.ˏ(this.ˏ);
        }
    }

    public void onConfigurationChanged(Configuration configuration) {
        super.onConfigurationChanged(configuration);
        if (configuration != null && this.ˊ != configuration.orientation) {
            this.ˊ = configuration.orientation;
            if (this.ˋ != null) {
                this.ˋ.ˊ(this.ˏ);
            }
        }
    }

    public boolean dispatchKeyEvent(KeyEvent keyEvent) {
        if (getVisibility() == 0 && keyEvent.getKeyCode() == 4 && keyEvent.getAction() == 0 && this.ˋ != null) {
            this.ˋ.ˎ(this.ˏ);
        }
        return super.dispatchKeyEvent(keyEvent);
    }

    protected void onAttachedToWindow() {
        super.onAttachedToWindow();
        if (dfe.ˊ().ॱ()) {
            ˎ();
        }
    }

    protected void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        if (dfe.ˊ().ॱ()) {
            dfe.ˊ().ˎ();
        }
    }

    private void ˎ() {
        dfe.ˊ().ˊ(new d(this) {
            final /* synthetic */ dfb ॱ;

            {
                this.ॱ = r1;
            }

            public void ˊ() {
                new Handler(Looper.getMainLooper()).post(new 2(this));
            }
        });
    }
}
